// import App from "next/app";
import React, { useEffect, useState, useRef } from "react";
import "viewerjs/dist/viewer.css";
import "../src/theme/antd.less";
import "../src/theme/reset.scss";
import { ViewApi } from "@/api/view";

let lastUrl;
function MyApp({ Component, pageProps }) {
  const url = useRef("");
  useEffect(() => {
    if (typeof window !== "undefined") {
      if (url !== lastUrl) {
        url.current = window.location.href;
        lastUrl = url.current;
        ViewApi.addView({ url: url.current });
      }
    }
  }, [url.current]);
  return <Component {...pageProps} />;
}

// Only uncomment this method if you have blocking data requirements for
// every single page in your application. This disables the ability to
// perform automatic static optimization, causing every page in your app to
// be server-side rendered.
//
// MyApp.getInitialProps = async (appContext) => {
//   // calls page's `getInitialProps` and fills `appProps.pageProps`
//   const appProps = await App.getInitialProps(appContext);
//
//   return { ...appProps }
// }

export default MyApp;
